package logic.teacherQuery_logic;

import java.util.List;

import javaRMI.RMIClient;
import logic.utility_logic.CourseQueryLogicsvFactory;
import logic.utility_logic.NoSuchElementException;
import logicsv.courseQuery_logicsv.CourseQueryLogicsv;
import po.TeacherPO;
import resultmessage.TeacherQueryRM;
import vo.CourseVO;
import vo.TeacherVO;
import datasv.datafactorysv.TeacherQueryDatasvFactory;
import datasv.teacherQuery_datasv.TeacherQueryDatasv;

public class TeacherList {
	private TeacherQueryDatasv teacherQD ;
	private CourseQueryLogicsv courseQL;
	public TeacherList(RMIClient rmi){
		 teacherQD = new TeacherQueryDatasvFactory(rmi).create();
		 courseQL = new CourseQueryLogicsvFactory(rmi).create();
	}
	public TeacherVO getTeacher(String teacherID){
		TeacherPO teacher = teacherQD.getTeacher(teacherID);
		List<CourseVO> courses = courseQL.getAllCouOfTea(teacherID);
		if(teacher == null || courses== null){
			throw new NoSuchElementException();
		}
		return new TeacherVO(teacher,courses);
	}
	public TeacherQueryRM addTeacher(TeacherPO teacher) {
		return teacherQD.addTeacher(teacher);
	}
	public TeacherQueryRM deleteTeacher(String teacherID) {
		return teacherQD.deleteTeacher(teacherID);
	}

	public TeacherQueryRM updateTeacher(TeacherPO teacher) {
		return teacherQD.updateTeacher(teacher);
	}


}
